package com.xy.tool.report.view;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zsp on 2018/12/7.
 */
public class Row {

    private int border = 1;
    private int height;
    private List<Cell> cellList;

    public Row withBorder(int value) {
        this.border = value;
        return this;
    }

    public void addCell(Cell cell) {
        if(cellList == null) {
            cellList = new ArrayList<>();
        }
        cellList.add(cell);
    }

    public void addCell(int index, Cell cell) {
        if(cellList == null) {
            cellList = new ArrayList<>();
        }
        cellList.add(index, cell);
    }

    public void addEmptyCell() {
        addCell(Cell.empty());
    }

    public void addEmptyCell(int index) {
        addCell(index, Cell.empty());
    }

    public void addAllEmptyCell(int size) {
        for(int i = 0; i < size; i++) {
            addCell(Cell.empty());
        }
    }

    public void addAllEmptyCell(int index, int size) {
        for(int i = 0; i < size; i++) {
            addCell(index, Cell.empty());
        }
    }

    public void removeCell(Cell cell) {
        if(cellList == null) {
            return;
        }
        cellList.remove(cell);
    }

    public int getBorder() {
        return border;
    }

    public void setBorder(int border) {
        this.border = border;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public List<Cell> getCellList() {
        return cellList;
    }
}
